home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / BPAS9.ARJ / FACTORIA.PAS < prev    next >
Pascal/Delphi Source File  |  1990-10-30  |  374b  |  25 lines

  1. PROGRAM Factorial;
  2.  
  3. USES
  4.   Crt;
  5.  
  6. VAR
  7.   N   :  Integer;
  8.  
  9. FUNCTION Fact ( N : Integer ) : Integer;
  10. BEGIN
  11.   IF N < 0 THEN Write (' N is undefined. ')
  12.   ELSE
  13.     IF N > 0 THEN
  14.       Fact := N * Fact ( N - 1 )
  15.     ELSE
  16.       Fact := 1
  17. END;
  18.  
  19. BEGIN
  20.   ClrScr;
  21.   WriteLn;
  22.   Write('Enter an integer: '); ReadLn ( N );
  23.   Write ( Fact ( N ): 10 );
  24.   ReadLn
  25. END.